<?php
require "libraries/modules/manga/scan_function.php";
if(isset($_POST['url'])){
	$url=$_POST['url'];
			if(preg_match("/hamtruyen.com/i",$_POST['url'])){
					
					//echo str_replace('?imgmax=3000','',$data);
					
					$data=geturl($_POST['url']);
				 	$html=str_get_html($data);
					
					foreach($html->find("img") as $val){
						$val=$val->src;
						if(strpos($val,"blogspot.com")!==false||strpos($val,"imgur")!==false||strpos($val,"bbmedia.hamtruyen.com")!==false||strpos($val,"tamtay.vn")!==false){
						$str.="<img src='".$val."'/>";
						}
					}
					
					
					$data= str_replace('?imgmax=2048','',$str);
					
				
					
						if(mb_strpos($data,'bbmedia.hamtruyen.com') !==false){
							$surl="content=".urlencode($data);
							$url = 'http://bk2.manga24h.com/index.php';
							$resultContent = mycurl($surl,$url);
							$data = urldecode($resultContent);
							echo $data;
						}else{
							echo $data;
						}
				
					exit();
	
	
	}
	
	
	if(preg_match("/truyen18.org/i",$_POST['url'])){
	
		$data=truyen18($_POST['url']);
		echo $data;
		exit();
	}
	
	if(preg_match("/blogtruyen.com/i",$_POST['url'])){
				$data=geturl($_POST['url']);
				$html=str_get_html($data);
			$str= $html->find('#content',0)->innertext;
			echo str_replace('?imgmax=2048','',$str);
		
		exit();
	
	}
		if(preg_match("/a3manga/i",$_POST['url'])){
				$data=a3manga($_POST['url']);
				// echo $data;
			$html=str_get_html($data);
			$str= $html->find('.view-chapter',0)->innertext;
			echo $str;
		//	echo str_replace('?imgmax=2048','',$str);
		
		exit();
	
	}
	
	
	if(preg_match("/dammetruyen/i",$_POST['url'])){
				$data=dammetruyen($_POST['url']);
				$html=str_get_html($data);
				$str= $html->find('#ajaxload_chap',0)->innertext;
				echo $str;
		
		exit();
	
	}
	
	if(preg_match("/vuatruyentranh/i",$_POST['url'])){
			$html=file_get_html($url);
			$str= $html->find('#pics',0)->innertext;
			echo $str;
			exit();
	
	}
	
	
	if(preg_match("/vuitruyentranh/i",$_POST['url'])){
					$link=$_POST['url'];
					$data=geturl($_POST['url']);
					$html=str_get_html($data);
		
			
			if(strpos($link,"mobile/truyen-tranh")!==false){
				$str= $html->find('.swipe-wrap',0)->innertext;
				$str=str_replace('src="http://vuimanga.static.game.zing.vn/resources/vmgmw/img/loading.gif" ',' ',$str);
				$str=str_replace('data-rel="http://vuimanga.static.game.zing.vn/resources/vmgmw/img/loading.gif"','',$str);
				$data=str_replace('data-src','src',$str); 
			}else{
					
				$str= $html->find('#contentWapper',0)->innertext;
				$str=str_replace('src="http://vuimanga.static.game.zing.vn/resources/vmg/img/1x1px.gif?v=52"',' ',$str);
				$data=str_replace('data-original','src',$str); 
			}
			$surl="content=".urlencode($data);
			$url = 'http://bk2.manga24h.com/index.php';
			$resultContent = mycurl($surl,$url);
			$data = urldecode($resultContent);
			
			
			
			echo $data;
			
		
		exit();
	
	}
	
		if(preg_match("/http:\/\/truyentranhnhanh.com/i",$_POST['url'])){
		
					$data=geturl($_POST['url']);
					$html=str_get_html($data);
					$data= $html->find('.neoslideshow',0)->innertext;
			
					$surl="content=".urlencode($data);
					$url = 'http://bk2.manga24h.com/index.php';
					$resultContent = mycurl($surl,$url);
					$data = urldecode($resultContent);
					echo $data;
					exit();
	
		}
		if(preg_match("/m.truyentranhnhanh.com/i",$_POST['url'])){
					$data=geturl($_POST['url']);
					$html=str_get_html($data);
					$data= $html->find('.noidung',0)->innertext;
			
					$surl="content=".urlencode($data);
					$url = 'http://bk2.manga24h.com/index.php';
					$resultContent = mycurl($surl,$url);
					$data = urldecode($resultContent);
					echo $data;
	
				exit();
	
		}
	
	
		if(preg_match("/vechai/i",$_POST['url'])){
					$data=geturl($_POST['url']);
					 	if(strpos($_POST['url'],'doctruyen.vechai')!==false){
				 
						$html=str_get_html($data);
									
						foreach($html->find('.entry2',0)->find("img") as $val){
								if(strpos($val->src,'blogspot.com')!==false){$data2.= "<img src='".$val->src."' />"."<Br/>";}
							}
						
						$data2= str_replace('?imgmax=2000','',$data2);
						
						
							if(mb_strpos($data2,'vechai.info') !==false){
								$surl="content=".urlencode($data2);
								$url = 'http://bk2.manga24h.com/index.php';
								$resultContent = mycurl($surl,$url);
								$data2 = urldecode($resultContent);
								echo $data2;
							}else{
								echo $data2;
							}
					}else{
					
							$html=str_get_html($data);
							foreach($html->find("#zoomtext",0)->find("img") as $val){
								if(strpos($val->src,'blogspot.com')!==false){$data2.= "<img src='".$val->src."' />"."<Br/>";}
							}
							echo $data2;
					}
					
					exit();
				
				//End of phantom
	}
	
		if(preg_match("/comicvn/i",$_POST['url'])){
					$data=geturl($_POST['url']);
					$html=str_get_html($data);
	
					$data=$html->find('#txtarea',0)->innertext;
					echo $data;
					exit();
	}
	
	

			if(preg_match("/truyentranhtuan.com/i",$_POST['url'])){
					$data=ttt($_POST['url']);
					
					//Check link co ttt thi ko duoc
					$pos=strpos($data,'truyentranhtuan');
					if($pos!==false){
				
					$surl="content=".urlencode($data);
					$url = 'http://bk2.manga24h.com/index.php';
					$resultContent = mycurl($surl,$url);
					$data = urldecode($resultContent);
					echo $data;
				//	echo $data;
					}else{
						echo $data;
					}
					//
					exit();
				
				//End of phantom
			}
			
		
				
			if(preg_match("/nhacvn/i",$_POST['url'])){
					$data=nhacvn($url);
				//	$data=$html->find('.chapter_slider',0)->innertext;
					echo str_replace('?imgmax=1300','',$data);
				
					exit();
				
				//End of phantom
			}
		
			
			if(preg_match("/truyentranh8/i",$_POST['url'])){
				$data=tt8_getimage($url);
				$data= str_replace('<img src="http://truyentranh8.com/templates/main/images/gioithieubanbe3.png" class="lazy">','',$data);
				$data= str_replace('?imgmax=1600','',$data);
				echo $data;
				exit();
				
				//End of phantom
			}
			
	if(preg_match("/truyenhay24h/i",$_POST['url'])){
					$data=truyenhay($_POST['url']);
					echo str_replace('?imgmax=2048','',$data);
					exit();
				
				//End of phantom
	}
}
exit();
?>
